<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8" />
    <title>系统sql管理</title>
    
    <link rel="stylesheet" href="/static/basic/plugins/easyui/themes/bootstrap/easyui.css" >
	<link rel="stylesheet" href="/static/basic/plugins/easyui/themes/icon.css" >
	<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
	<script src="/static/basic/plugins/easyui/jquery.easyui.min.js"></script>
	<script src="/static/init.js?v=07281"></script>
	<script src="/static/searchEdit.js?v=122"></script>
	<script src="/static/basic/plugins/easyui/locale/easyui-lang-zh_CN.js"></script>
	<script src="https://cdn.staticfile.org/moment.js/2.24.0/moment.min.js"></script>
	<link rel="stylesheet" type="text/css" href="/static/m.css" >
</head>
<body>
<div id="window-mmask" class="window-mmask" ><div class="window-mmask-msg" >页面加载中,请稍候...</div></div>
<div class="easyui-layout" data-options="fit:true"  >
	<div data-options="region:'center'" >
		<table id="gridList" ></table>
	</div>
</div>
<div id="searchbar" >
	<div class="maction">
		<a href="javascript:void(0)" id="addButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">新增</a>
		<a href="javascript:func_1()" id="generateButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">生成</a>
		<a href="javascript:void(0)" id="editButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">编辑</a>
		<a href="javascript:void(0)" id="removeButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-remove'">删除</a>
		<a href="javascript:void(0)" id="showChangesButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">信息变更提示</a>
        <a href="javascript:void(0)" id="cancelEditButton" class="easyui-linkbutton" data-options="plain:true" >取消当前行编辑</a>
        <a href="javascript:void(0)" id="endEditingButton" class="easyui-linkbutton" data-options="plain:true" >结束当前行编辑</a>
        <a href="javascript:void(0)" id="rejectButton" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" >撤销</a>
		<a href="javascript:void(0)" id="saveButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save'">保存</a>
		<!-- <a href="javascript:void(0)" id="addButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-delete'">导出</a> -->
	</div>
	<form id="searchForm" >
		名称like:<input id="search-sql_name" name="sql_name"  class="easyui-textbox isearch" style="width:300px;">
	值like:<input id="search-sql_value" name="sql_value"  class="easyui-textbox isearch" style="width:300px;">
	<a id="searchButton" href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'" >查询</a>
	</form>
</div>
		
		

<div id="dialog_1" class="easyui-dialog" title="生成sql" data-options="closed:true,modal:true,iconCls:'icon-win'" style="width:700px;height:400px">
	<div class="easyui-layout" data-options="fit:true,border:false"  style="height:100%;width:100%;">
		<div data-options="region:'center',border:false" style="height:100%;width:100%;">
			<div data-options="fit:true,border:false" class="easyui-panel" title="" style="height:100%;width:100%;">
				<form id="form_1" method="post" >
					<table class="ets" style="height:100%;width:500px;padding-left:0px">
						<tr>
							<td>生成类型:</td>
							<td>
							    <select class="easyui-combobox" name="generate_type" data-options="editable:false" >
							        <option value="gridsql">gridsql</option>
							        <option value="insert">insert</option>
							        <option value="update">update</option>
							        <option value="get">get</option>
							    </select>
							</td>
						</tr>
						<tr>
							<td>表名:</td>
							<td><input type="text" id="table_name" name="table_name" class="easyui-textbox"></input></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		<div data-options="region:'south',border:false" style="height:55px;width:100%;padding-top:10px;">
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:save_1()">保存</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="javascript:closeDialog('dialog_1')">取消</a>
		</div>
	</div>
</div>
<script>
var options={
		page_id:2,
		grid_id:"gridList",
		sqlname:"grid_sys_sql",
		loadurl:"/authenticated/sys/sql/list",
		saveurl:"/authenticated/sys/sql/update",
		showCheckbox:false,
		rownumbers:false,
		gridParam:{sort:"id",order:"desc"}
	};
		//document ready
		$(function(){
			grid1=new uniontrip.datagrid.searchEdit(options);
			//初始化检索条件
			$('#addButton').bind('click', addRow);//新增行绑定事件
			$('#saveButton').bind('click', grid1.accept);//保存datagrid绑定事件
			$('#cancelEditButton').bind('click',grid1.cancelEditing);//取消行编辑绑定事件
			$('#endEditingButton').bind('click', grid1.endEditing);//结束行编辑绑定事件
			$('#rejectButton').bind('click', grid1.rejectChanges);//撤销编辑绑定事件		
			$('#editButton').bind('click',grid1.editRow);//编辑按钮绑定事件
		    $('#removeButton').bind('click',grid1.remove);//删除行绑定事件
		    $('#searchButton').bind('click',grid1.load);//查询操作绑定事件
		    //$('#formCancelButton').bind('click', formCancelButton);
		    $('#showChangesButton').bind('click',grid1.showChanges);
		    
		    $('#search-sql_name').textbox().textbox('addClearBtn', 'icon-clear');
		});

		/**
		 * 新增一行
		 */
	    function addRow(){
	    	var newRowData={id:guid()};//初始化行数据
	    	grid1.grid.datagrid('append',newRowData);
	    	
	    }
	function save_1(){
		var formObject=$("#form_1").serializeObject();
		$.post("/authenticated/generate/sql",JSON.stringify(formObject),function(result){
			if(result.success){
				$.messager.alert("提示", "保存成功！");
				grid1.grid.datagrid("load");
			}else{
				$.messager.alert("提示", "保存失败！\n"+result.message);
			}
		});
	}
	function func_1(item){
		//var name=item.name;	
		//generteParam.type=name;
		$('#dialog_1').dialog('open');
	}
</script>
</body>
</html>